CMAKE_MINIMUM_REQUIRED(VERSION 3.16.3 FATAL_ERROR)


if (POLICY CMP0068)
	cmake_policy(SET CMP0068 NEW)
	set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
endif ()

if(POLICY CMP0075)
	cmake_policy(SET CMP0075 NEW)
endif()

if (POLICY CMP0077)
	cmake_policy(SET CMP0077 NEW)
endif ()

#===--------------------------------------------------------------
# project setup
#===--------------------------------------------------------------

project(plc2llvm)
set(CMAKE_CXX_STANDARD 20)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)

#===--------------------------------------------------------------
# llvm configure
#===--------------------------------------------------------------
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

# 引入llvm/antlr以及项目头文件
include_directories(
		${LLVM_INCLUDE_DIRS}
		${PROJECT_SOURCE_DIR}/include
		${ANTLR_INCLUDE_DIR}
)

# 引入llvm宏定义
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})

# 打开 exception 和RTTI
set(LLVM_ENABLE_RTTI ON)
set(LLVM_ENABLE_EH ON)

add_subdirectory(src)